<!-- subpkg_medicine/pay_result/index.vue -->
<script lang="ts" setup>
  import { getMedicalOrderDetail } from '@/apis/medicine'
  import type { MedicalOrderDetail } from '@/types/medicineOrder'
  import { onLoad } from '@dcloudio/uni-app'
  import { ref } from 'vue'

  const props = defineProps<{
    orderId: string
  }>()

  const OrderDetail = ref<MedicalOrderDetail>()

  const getData = async () => {
    const res = await getMedicalOrderDetail(props.orderId)
    console.log(res)

    OrderDetail.value = res
  }

  onLoad(() => {
    getData()
  })
</script>
<template>
  <view class="pay-result-page">
    <view class="result" v-if="OrderDetail?.status === 10">
      <uni-icons size="70" color="#f00" type="clear" />
      <view class="amount">¥ {{ OrderDetail?.actualPayment }}</view>
      <view class="label">支付失败</view>
      <view class="tips">订单支付失败，请回订单中心重新支付</view>
    </view>

    <view class="result" v-else>
      <uni-icons size="70" color="#20c6b2" type="checkbox-filled" />
      <view class="amount">¥ {{ OrderDetail?.actualPayment }}</view>
      <view class="label">支付成功</view>
      <view class="tips">订单支付成功，已通知药房尽快发出，请耐心等待~</view>
    </view>

    <view class="buttons">
      <navigator
        hover-class="none"
        :url="`/subpkg_medicine/order_detail/order_detail?id=${OrderDetail?.id}`"
        class="uni-button"
      >
        查看订单
      </navigator>
      <navigator
        hover-class="none"
        :url="`/subpkg_consult/room/room?orderId=${OrderDetail?.roomId}`"
        open-type="redirect"
        class="uni-button plain"
      >
        返回诊室
      </navigator>
    </view>
  </view>
</template>

<style lang="scss">
  @import './pay_result.scss';
</style>
